package com.huangpuweb.api.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.huangpuweb.api.model.*;
import com.huangpuweb.api.model.dto.DianZhaoDianPaiDto;
import com.huangpuweb.api.service.ShiGongAnQuanApiService;
import com.huangpuweb.api.util.MapUtil;
import com.huangpuweb.api.util.StringUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping(value = "/shiGongAnQuan")
public class ShiGongAnQuanController {

    private static Logger logger = Logger.getLogger(ShiGongAnQuanController.class);

    private ShiGongAnQuanApiService shiGongAnQuanApiService;


    @Autowired
    public void setShiGongAnQuanApiService(ShiGongAnQuanApiService shiGongAnQuanApiService) {
        this.shiGongAnQuanApiService = shiGongAnQuanApiService;
    }

    /**
     * 获取施工工地视频
     */
    @RequestMapping(value = "/getListSysConstructionProjectVideo")
    public void getListSysConstructionProjectVideo(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        List<SysConstructionProjectVideo> sysConstructionProjectVideoList = shiGongAnQuanApiService.getAllListSysConstructionProjectVideoByNumber();

        for (SysConstructionProjectVideo s : sysConstructionProjectVideoList) {
            double[] map = MapUtil.bd09towgs84(Double.parseDouble(s.getLng()), Double.parseDouble(s.getLat()));
            s.setLng(map[0] + "");
            s.setLat(map[1] + "");
        }
        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", sysConstructionProjectVideoList);
        responseData(resultObj.toString(), resp);
    }

    /**
     * 获取深基坑列表
     */
    @RequestMapping(value = "/getListShengJiKengProject")
    public void getListShengJiKengProject(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        String content = "";
        LogFactory.getLog(this.getClass()).info("------getListShengJiKengProject-----start-------");
        try {
            String url = "http://10.81.71.61:8002/api/ExternalApi/GetProjects?token=SG6UEurVJC/Z6772cYj3ig==";

            HttpClient httpClient = new DefaultHttpClient();
            HttpGet get = new HttpGet(url);
            HttpResponse response = httpClient.execute(get);
            content = EntityUtils.toString(response.getEntity());


        } catch (IOException e) {
            resultObj.put("error_code", 0);
            resultObj.put("error_msg", "获取成功");
            resultObj.put("data", content);
            responseData(resultObj.toString(), resp);
            return;
        }


        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", content);
        responseData(resultObj.toString(), resp);

    }


    /**
     * 根据项目ＩＤ获取监测数据
     */
    @RequestMapping(value = "/getShengJiKengProjectById")
    public void getShengJiKengProjectById(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getShengJiKengProjectById-----start-------");
        String content = "";
        String str = getRequestBodyString(req);
        if (StringUtil.isEmpty(str)) {
            responseErrorData("json error", resp);
            return;
        }
        JSONObject jsonObject = JSONObject.parseObject(str);
        //施工工地ID
        String projectid = jsonObject.getString("projectid");

        try {
            String url = "http://10.81.71.61:8002/api/ExternalApi/GetSummaryList?PID=" + projectid + "&token=SG6UEurVJC/Z6772cYj3ig==";

            HttpClient httpClient = new DefaultHttpClient();
            HttpGet get = new HttpGet(url);
            HttpResponse response = httpClient.execute(get);
            content = EntityUtils.toString(response.getEntity());


        } catch (IOException e) {
            resultObj.put("error_code", 0);
            resultObj.put("error_msg", "获取成功");
            resultObj.put("data", content);
            responseData(resultObj.toString(), resp);
            return;
        }


        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", content);
        responseData(resultObj.toString(), resp);
    }


    /**
     * 根据工程名称获取工程信息
     */
    @RequestMapping(value = "/getBuildInfoByProjectName")
    public void getBuildInfoByProjectName(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getBuildInfoByProjectName-----start-------");

        String str = getRequestBodyString(req);
        if (StringUtil.isEmpty(str)) {
            responseErrorData("json error", resp);
            return;
        }
        JSONObject jsonObject = JSONObject.parseObject(str);
        //施工工地ID
        String projectname = jsonObject.getString("projectname");
        String number = jsonObject.getString("number");
        SysConstructionProject sp = shiGongAnQuanApiService.getBuildInfoByProjectNameInfo(projectname,number);
        List<SysConstructionProjectVideo> listSysConstructionProjectVideo = shiGongAnQuanApiService.getListSysConstructionProjectVideoByNumber(sp.getNumber(),number);
        List<SysConstructionProjectVideo> same = new ArrayList<>();
        List<SysConstructionProjectVideo> different = new ArrayList<>();
        if (listSysConstructionProjectVideo.size()==0){
            sp.setSame(same);
        }
        for (SysConstructionProjectVideo ls : listSysConstructionProjectVideo) {
            if (listSysConstructionProjectVideo.size() == 0 || listSysConstructionProjectVideo == null) {
                sp.setSame(new ArrayList<SysConstructionProjectVideo>());
            }
            if (!sp.getProject_name().equals(ls.getProject_name())) {
                different.add(ls);
                sp.setDifferent(different);
                sp.setSame(new ArrayList<SysConstructionProjectVideo>());
            }
            if (sp.getProject_name().equals(ls.getProject_name())) {
                same.add(ls);
                sp.setSame(same);
            }
        }


        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", sp);
        responseData(resultObj.toString(), resp);
    }


    /**
     * 改扩建项目工程列表
     */
    @RequestMapping(value = "/getSysGaiKuoJianListData")
    public void getSysGaiKuoJianListData(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getSysGaiKuoJianListData-----start-------");
        //状态 (t 土建项目、g 改扩建项目、z装饰装修项目)
        List<SysConstructionProject> listSysConstructionProject = shiGongAnQuanApiService.getListSysConstructionProjectByGkj();
        for (SysConstructionProject s : listSysConstructionProject) {
            try {
                if (StringUtil.isNotEmpty(s.getX_y())) {
                    String[] xlist = s.getX_y().split(",");
                    String[] lnglat = xlist[0].split("/");

                    double[] map = MapUtil.bd09towgs84(Double.parseDouble(lnglat[0]), Double.parseDouble(lnglat[1]));
                    s.setLng(map[0] + "");
                    s.setLat(map[1] + "");
                } else {
                    s.setLng("");
                    s.setLat("");
                }
            } catch (Exception e) {
                continue;
            }

        }


        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", listSysConstructionProject);
        responseData(resultObj.toString(), resp);
    }

    /**
     * 土建项目工程列表
     */
    @RequestMapping(value = "/getSysTujianListData")
    public void getSysTujianListData(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getSysTujianListData-----start-------");
        //状态 (t 土建项目、g 改扩建项目、z装饰装修项目)
        List<SysConstructionProject> listSysConstructionProject = shiGongAnQuanApiService.getListSysConstructionProjectByTJ();
        for (SysConstructionProject s : listSysConstructionProject) {
            try {
                if (StringUtil.isNotEmpty(s.getX_y())) {
                    String[] xlist = s.getX_y().split(",");
                    String[] lnglat = xlist[0].split("/");

                    double[] map = MapUtil.bd09towgs84(Double.parseDouble(lnglat[0]), Double.parseDouble(lnglat[1]));
                    s.setLng(map[0] + "");
                    s.setLat(map[1] + "");
                } else {
                    s.setLng("");
                    s.setLat("");
                }
            } catch (Exception e) {
                continue;
            }
        }
        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", listSysConstructionProject);
        responseData(resultObj.toString(), resp);
    }

    /**
     * 装饰装修工程列表
     */
    @RequestMapping(value = "/getSysZhuangShiListData")
    public void getSysZhuangShiListData(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getSysZhuangShiListData-----start-------");
        //状态 (t 土建项目、g 改扩建项目、z装饰装修项目)
        List<SysConstructionProject> listSysConstructionProject = shiGongAnQuanApiService.getListSysConstructionProjectByZS();
        for (SysConstructionProject s : listSysConstructionProject) {
            try {
                if (StringUtil.isNotEmpty(s.getX_y())) {
                    String[] xlist = s.getX_y().split(",");
                    String[] lnglat = xlist[0].split("/");
                    double[] map = MapUtil.bd09towgs84(Double.parseDouble(lnglat[0]), Double.parseDouble(lnglat[1]));
                    s.setLng(map[0] + "");
                    s.setLat(map[1] + "");
                } else {
                    s.setLng("");
                    s.setLat("");
                }
            } catch (Exception e) {
                continue;
            }
        }
        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", listSysConstructionProject);
        responseData(resultObj.toString(), resp);
    }


    /**
     * 大型装饰工程分析-数据分析
     */
    @RequestMapping(value = "/getSysZhuangShiTypeData")
    public void getSysZhuangShiTypeData(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getSysZhuangShiTypeData-----start-------");

        Integer allTypeZcount = shiGongAnQuanApiService.getAllTypeCount("Z");
        //1000万以上的项目
        Integer allType1000Zcount = shiGongAnQuanApiService.getAllTypeCount1000();
        Integer allType500Zcount = allTypeZcount - allType1000Zcount;
        resultJson.put("allType1000Zcount", allType1000Zcount);
        double allType1000Zcountp = (double) allType1000Zcount / allTypeZcount;
        resultJson.put("before1000percent", String.format("%.1f", allType1000Zcountp * 100) + "%");

        double allType500Zcountp = 1 - allType1000Zcountp;
        resultJson.put("last1000Count", allTypeZcount-allType1000Zcount);
        resultJson.put("last1000percent", String.format("%.1f", allType500Zcountp * 100) + "%");

        //历年项目不分类
        Integer notypecount = shiGongAnQuanApiService.getImportCount("历年项目不分类");
        //特殊类建筑装饰装修工程
        Integer importcount = shiGongAnQuanApiService.getImportCount("特殊类建筑装饰装修工程");
        double importcountp = (double) importcount / allTypeZcount;
        double notypecountp = (double) notypecount / allTypeZcount;
        resultJson.put("importcountpercent", Math.round(importcountp * 100) + "%");
        resultJson.put("importcount", importcount);
        resultJson.put("notypecountpercent", Math.round(notypecountp * 100) + "%");
        resultJson.put("notypecount", notypecount);
        //  Math.round(percent*100) + "%"
        double noimportcountp = 1 - importcountp - notypecountp;
        resultJson.put("noimportcountpercent", Math.round(noimportcountp * 100) + "%");
        resultJson.put("noimportcount", allTypeZcount-importcount-notypecount);
        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", resultJson);
        responseData(resultObj.toString(), resp);
    }


    /**
     * 大型土建工程分析-数据分析
     */
    @RequestMapping(value = "/getSysLargeBuildingTypeData")
    public void getSysLargeBuildingTypeData(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getSysLargeBuildingTypeData-----start-------");

        //塔吊数量
        Integer tower_crane_sumcount = shiGongAnQuanApiService.gettower_crane_sumcount();
        //人货梯数量
        Integer person_ladder_sumcount = shiGongAnQuanApiService.getperson_ladder_sumcount();
        //吊篮数量
        Integer nacelle_numcount = shiGongAnQuanApiService.getnacelle_numcount();


        List<SysHpXiaoFangAjType> listSysHpXiaoFangAjType = shiGongAnQuanApiService.getImageScheduleByDate();


        resultJson.put("tower_crane_sumcount", tower_crane_sumcount);
        resultJson.put("person_ladder_sumcount", person_ladder_sumcount);
        resultJson.put("nacelle_numcount", nacelle_numcount);
        resultJson.put("listSysHpXiaoFangAjType", listSysHpXiaoFangAjType);
        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", resultJson);
        responseData(resultObj.toString(), resp);
    }


    /**
     * 大型工程分析-工程分布
     */
    @RequestMapping(value = "/getSysLargeBuildingStreetData")
    public void getSysLargeBuildingStreetData(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getSysLargeBuildingStreetData-----start-------");
        List<String> streetlist = shiGongAnQuanApiService.getListStreetInfo();

        JSONArray jsonArray = new JSONArray();
        JSONObject jsonObject = null;
        for (String street : streetlist) {

            jsonObject = new JSONObject();
            List<SysHpXiaoFangAjType> listStreetBuildInfo = shiGongAnQuanApiService.getListStreetBuildInfo(street);
            Boolean tflag = false;
            Boolean gflag = false;
            Boolean zflag = false;
            for (SysHpXiaoFangAjType sj : listStreetBuildInfo) {
                if (sj.getName().equals("t")) {
                    tflag = true;
                }

                if (sj.getName().equals("g")) {
                    gflag = true;
                }

                if (sj.getName().equals("z")) {
                    zflag = true;
                }


            }
            SysHpXiaoFangAjType newsj = null;
            if (tflag == false) {
                newsj = new SysHpXiaoFangAjType();
                newsj.setName("t");
                newsj.setCount("0");
                listStreetBuildInfo.add(newsj);
            }


            if (zflag == false) {
                newsj = new SysHpXiaoFangAjType();
                newsj.setName("z");
                newsj.setCount("0");
                listStreetBuildInfo.add(newsj);
            }


            if (gflag == false) {
                newsj = new SysHpXiaoFangAjType();
                newsj.setName("g");
                newsj.setCount("0");
                listStreetBuildInfo.add(newsj);
            }

            if (StringUtils.isNotEmpty(street)) {
                jsonObject.put("street", street);

                jsonObject.put("listStreetBuildInfo", listStreetBuildInfo);
                jsonArray.add(jsonObject);
            }

        }

        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", jsonArray);
        responseData(resultObj.toString(), resp);
    }


    /**
     * 各建设单位/设计单位/施工单位/监理单位数据接口
     */
    @RequestMapping(value = "/getListUnitByData")
    public void getListUnitByData(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getListUnitByData-----start-------");

        String str = getRequestBodyString(req);
        if (StringUtil.isEmpty(str)) {
            responseErrorData("json error", resp);
            return;
        }
        JSONObject jsonObject = JSONObject.parseObject(str);
        //0建设单位/1设计单位/2施工单位/3监理单位
        String type = jsonObject.getString("type");

        JSONArray jsonArray = new JSONArray();
        JSONObject unitjson = null;
        List<String> listname = shiGongAnQuanApiService.getListUnitNameByType(type);

        for (String name : listname) {
            unitjson = new JSONObject();
            unitjson.put("name", name);
            List<SysConstructionProject> listSysConstructionProject = shiGongAnQuanApiService.getListSysConstructionProjectByName(type, name);
            for (SysConstructionProject s : listSysConstructionProject) {
                try {
                    if (StringUtil.isNotEmpty(s.getX_y())) {
                        String[] xlist = s.getX_y().split(",");
                        String[] lnglat = xlist[0].split("/");
                        double[] map = MapUtil.bd09towgs84(Double.parseDouble(lnglat[0]), Double.parseDouble(lnglat[1]));
                        s.setLng(map[0] + "");
                        s.setLat(map[1] + "");
                    } else {
                        s.setLng("");
                        s.setLat("");
                    }
                } catch (Exception e) {
                    continue;
                }

            }
            unitjson.put("listSysConstructionProject", listSysConstructionProject);
            jsonArray.add(unitjson);

        }

        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", jsonArray);
        responseData(resultObj.toString(), resp);
    }

    /**
     * 大型工程左侧数据总览
     */
    @RequestMapping(value = "/getSysLargeBuildingData")
    public void getSysLargeBuildingData(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getSysLargeBuildingData-----start-------");


        //总工程造价 亿元
        Double allCost = shiGongAnQuanApiService.getAllCost();
        //大型工程总数
        Integer allcount = shiGongAnQuanApiService.getAllCount();
        //总建设面积
        Double allArea = shiGongAnQuanApiService.getAllArea();
        //装饰装修项目
        Integer allTypeZcount = shiGongAnQuanApiService.getAllTypeCount("Z");

        //大型土建项目
        Integer allTypeTcount = shiGongAnQuanApiService.getAllTypeCount("t");
        //改造扩建项目
        Integer allTypeGcount = shiGongAnQuanApiService.getAllTypeCount("g");
        //建设单位
        Integer constructionunitcount = shiGongAnQuanApiService.getConstructionUnitCount();
        //设计单位
        Integer architectcount = shiGongAnQuanApiService.getarchitectCount();
        //施工单位
        Integer roadworkunitcount = shiGongAnQuanApiService.getroadworkunitcount();
        //监理单位
        Integer supervisingunitcount = shiGongAnQuanApiService.getsupervisingunitcount();

        resultJson.put("allCost", Math.round(allCost / 10000));
        resultJson.put("allcount", allcount);
        resultJson.put("allArea", allArea);
        resultJson.put("allTypeZcount", allTypeZcount);
        resultJson.put("allTypeTcount", allTypeTcount);
        resultJson.put("allTypeGcount", allTypeGcount);
        resultJson.put("constructionunitcount", constructionunitcount);
        resultJson.put("architectcount", architectcount);
        resultJson.put("roadworkunitcount", roadworkunitcount);
        resultJson.put("supervisingunitcount", supervisingunitcount);


        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", resultJson);
        responseData(resultObj.toString(), resp);

    }


    /**
     * 获取老西门街道施工轮播数据
     */
    @RequestMapping(value = "/getSysBuildingInfoWall")
    public void getSysBuildingInfoWall(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getSysBuildingInfoWall-----start-------");
        List<SysBuildingInfoWall> listSysBuildingInfoWall = shiGongAnQuanApiService.listSysBuildingInfoWall();
        for (SysBuildingInfoWall ss : listSysBuildingInfoWall) {
            try {
                double[] map = MapUtil.bd09towgs84(Double.parseDouble(ss.getLng()), Double.parseDouble(ss.getLat()));
                ss.setLng(map[0] + "");
                ss.setLat(map[1] + "");
            } catch (Exception e) {
                continue;
            }

        }

        resultJson.put("listSysBuildingInfoWall", listSysBuildingInfoWall);
        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", resultJson);
        responseData(resultObj.toString(), resp);

    }


    /**
     * 老西门街道-工程网格数据
     */
    @RequestMapping(value = "/getSysBuildingInfoStreetByNet")
    public void getSysBuildingInfoStreetByNet(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getSysBuildingInfoStreetByNet-----start-------");

        JSONArray jsonArray = new JSONArray();
        JSONObject ajson = new JSONObject();
        ajson.put("name", "0701网格");
        List<SysBuildingInfoStreet> listSysBuildingInfoStreet = shiGongAnQuanApiService.listSysBuildingInfoStreetNet("701");
        ajson.put("count", listSysBuildingInfoStreet.size());
        jsonArray.add(ajson);


        ajson = new JSONObject();
        ajson.put("name", "0702网格");
        listSysBuildingInfoStreet = shiGongAnQuanApiService.listSysBuildingInfoStreetNet("702");
        ajson.put("count", listSysBuildingInfoStreet.size());
        jsonArray.add(ajson);

        ajson = new JSONObject();
        ajson.put("name", "0703网格");
        listSysBuildingInfoStreet = shiGongAnQuanApiService.listSysBuildingInfoStreetNet("703");
        ajson.put("count", listSysBuildingInfoStreet.size());
        jsonArray.add(ajson);


        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", jsonArray);
        responseData(resultObj.toString(), resp);


    }


    /**
     * 老西门街道-工程状态
     */
    @RequestMapping(value = "/getSysBuildingInfoStreetByType")
    public void getSysBuildingInfoStreetByType(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getSysBuildingInfoStreetByType-----start-------");


        //发现新工程
        //受理待审核
        //受理审核通过
        //工程检查
        //工程已竣工
        JSONArray jsonArray = new JSONArray();
        JSONObject ajson = new JSONObject();
        ajson.put("name", "发现新工程");
        List<SysBuildingInfoStreet> listSysBuildingInfoStreet = shiGongAnQuanApiService.listSysBuildingInfoStreetType("发现工程");
        if (listSysBuildingInfoStreet == null) {
            ajson.put("count", 0);
            ajson.put("dataarray", "");
        } else {
            ajson.put("count", listSysBuildingInfoStreet.size());

            for (SysBuildingInfoStreet ss : listSysBuildingInfoStreet) {
                double[] map = MapUtil.bd09towgs84(Double.parseDouble(ss.getLng()), Double.parseDouble(ss.getLat()));
                ss.setLng(map[0] + "");
                ss.setLat(map[1] + "");
            }
            ajson.put("dataarray", listSysBuildingInfoStreet);
        }
        jsonArray.add(ajson);

        ajson = new JSONObject();
        ajson.put("name", "受理待审核");
        listSysBuildingInfoStreet = shiGongAnQuanApiService.listSysBuildingInfoStreetType("受理待审核");
        if (listSysBuildingInfoStreet == null) {
            ajson.put("count", 0);
            ajson.put("dataarray", "");
        } else {
            ajson.put("count", listSysBuildingInfoStreet.size());
            for (SysBuildingInfoStreet ss : listSysBuildingInfoStreet) {
                double[] map = MapUtil.bd09towgs84(Double.parseDouble(ss.getLng()), Double.parseDouble(ss.getLat()));
                ss.setLng(map[0] + "");
                ss.setLat(map[1] + "");
            }
            ajson.put("dataarray", listSysBuildingInfoStreet);
        }


        jsonArray.add(ajson);


        ajson = new JSONObject();
        ajson.put("name", "受理审核通过");
        listSysBuildingInfoStreet = shiGongAnQuanApiService.listSysBuildingInfoStreetType("受理审核通过");
        if (listSysBuildingInfoStreet == null) {
            ajson.put("count", 0);
            ajson.put("dataarray", "");
        } else {
            ajson.put("count", listSysBuildingInfoStreet.size());
            for (SysBuildingInfoStreet ss : listSysBuildingInfoStreet) {
                double[] map = MapUtil.bd09towgs84(Double.parseDouble(ss.getLng()), Double.parseDouble(ss.getLat()));
                ss.setLng(map[0] + "");
                ss.setLat(map[1] + "");
            }
            ajson.put("dataarray", listSysBuildingInfoStreet);
        }


        jsonArray.add(ajson);


        ajson = new JSONObject();
        ajson.put("name", "工程检查");
        listSysBuildingInfoStreet = shiGongAnQuanApiService.listSysBuildingInfoStreetType("工程检查");
        if (listSysBuildingInfoStreet == null) {
            ajson.put("count", 0);
            ajson.put("dataarray", "");
        } else {
            ajson.put("count", listSysBuildingInfoStreet.size());
            for (SysBuildingInfoStreet ss : listSysBuildingInfoStreet) {
                double[] map = MapUtil.bd09towgs84(Double.parseDouble(ss.getLng()), Double.parseDouble(ss.getLat()));
                ss.setLng(map[0] + "");
                ss.setLat(map[1] + "");
            }
            ajson.put("dataarray", listSysBuildingInfoStreet);
        }


        jsonArray.add(ajson);

        ajson = new JSONObject();
        ajson.put("name", "工程已竣工");
        listSysBuildingInfoStreet = shiGongAnQuanApiService.listSysBuildingInfoStreetType("竣工");
        if (listSysBuildingInfoStreet == null) {
            ajson.put("count", 0);
            ajson.put("dataarray", "");
        } else {
            ajson.put("count", listSysBuildingInfoStreet.size());
            for (SysBuildingInfoStreet ss : listSysBuildingInfoStreet) {
                double[] map = MapUtil.bd09towgs84(Double.parseDouble(ss.getLng()), Double.parseDouble(ss.getLat()));
                ss.setLng(map[0] + "");
                ss.setLat(map[1] + "");
            }
            ajson.put("dataarray", listSysBuildingInfoStreet);
        }


        jsonArray.add(ajson);

        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", jsonArray);
        responseData(resultObj.toString(), resp);

    }

    /**
     * 获取老西门街道施工轮播数据
     */
    @RequestMapping(value = "/getSysBuildingInfoStreet")
    public void getSysBuildingInfoStreet(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getSysBuildingInfoStreet-----start-------");


        List<SysBuildingInfoStreet> listSysBuildingInfoStreet = shiGongAnQuanApiService.listSysBuildingInfoStreet();
        for (SysBuildingInfoStreet ss : listSysBuildingInfoStreet) {
            double[] map = MapUtil.bd09towgs84(Double.parseDouble(ss.getLng()), Double.parseDouble(ss.getLat()));
            ss.setLng(map[0] + "");
            ss.setLat(map[1] + "");
        }
        resultJson.put("listSysBuildingInfoStreet", listSysBuildingInfoStreet);
        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", resultJson);
        responseData(resultObj.toString(), resp);

    }


    /**
     * 电招电牌专门获取老西门街道详情
     */
    @RequestMapping(value = "/getAllHpDianZhaoDianPaiInfoByXiMenStreet")
    public void getAllHpDianZhaoDianPaiInfoByXiMenStreet(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getAllHpDianZhaoDianPaiInfoByXiMenStreet-----start-------");


        List<HpDianZhaoDianPaiInfo> listHpDianZhaoDianPaiInfo = shiGongAnQuanApiService.llistHpDianZhaoDianPaiInfoXiMenStreet("老西门");
        for (HpDianZhaoDianPaiInfo ss : listHpDianZhaoDianPaiInfo) {
            double[] map = MapUtil.bd09towgs84(Double.parseDouble(ss.getBaiduLongitude()), Double.parseDouble(ss.getBaiduLatitude()));
            ss.setBaiduLongitude(map[0] + "");
            ss.setBaiduLatitude(map[1] + "");
        }

        resultJson.put("listHpDianZhaoDianPaiInfo", listHpDianZhaoDianPaiInfo);
        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", resultJson);
        responseData(resultObj.toString(), resp);

    }


    /**
     * 根据店招店牌等级获取列表(A/B/C)
     */
    @RequestMapping(value = "/getAllHpDianZhaoDianPaiInfoByCondition")
    public void getAllHpDianZhaoDianPaiInfoByCondition(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getAllHpDianZhaoDianPaiInfoByCondition-----start-------");

        String str = getRequestBodyString(req);
        if (StringUtil.isEmpty(str)) {
            responseErrorData("json error", resp);
            return;
        }
        JSONObject jsonObject = JSONObject.parseObject(str);
        //施工工地ID
        String street = jsonObject.getString("street");
        //施工工地ID
        String size = jsonObject.getString("size");
        //施工工地ID
        String heigthlevel = jsonObject.getString("heigthlevel");
        //施工工地ID
        String xingshi = jsonObject.getString("xingshi");
        //施工工地ID
        String level = jsonObject.getString("level");
        //风景区
        String travelname = jsonObject.getString("travelname");

        //删除实时转换逻辑，已在数据库层面添加字段解决了
        List<HpDianZhaoDianPaiInfo> listHpDianZhaoDianPaiInfo = shiGongAnQuanApiService.llistHpDianZhaoDianPaiInfoCondition(street, size, heigthlevel, xingshi, level, travelname);
        listHpDianZhaoDianPaiInfo.forEach(item -> {
            item.setBaiduLatitude(item.getWgs84Latitude());
            item.setBaiduLongitude(item.getWgs84Longitude());
        });
     /*   for (HpDianZhaoDianPaiInfo ss : listHpDianZhaoDianPaiInfo) {
            ss.setBaiduLongitude(ss.getWgs84Longitude());
            ss.setBaiduLatitude(ss.getWgs84Latitude());
        }
      */
        if (StringUtil.isNotEmpty(street)) {
            List<HpDianZhaoDianPaiTypeNameInfo> sizelist = shiGongAnQuanApiService.getDZDPSizeList(street);
            List<HpDianZhaoDianPaiTypeNameInfo> heigthlevellist = shiGongAnQuanApiService.getheigthlevelList(street);
            List<HpDianZhaoDianPaiTypeNameInfo> xingshilist = shiGongAnQuanApiService.getxingshiList(street);
            List<HpDianZhaoDianPaiTypeNameInfo> levellist = shiGongAnQuanApiService.getlevelList(street);
            resultJson.put("sizelist", sizelist);
            resultJson.put("heigthlevellist", heigthlevellist);
            resultJson.put("xingshilist", xingshilist);
            resultJson.put("levellist", levellist);
        }


        if (StringUtil.isNotEmpty(travelname)) {
            List<HpDianZhaoDianPaiTypeNameInfo> sizelist = shiGongAnQuanApiService.getDZDPSizeListBytravelname(travelname);
            List<HpDianZhaoDianPaiTypeNameInfo> heigthlevellist = shiGongAnQuanApiService.getheigthlevelListBytravelname(travelname);
            List<HpDianZhaoDianPaiTypeNameInfo> xingshilist = shiGongAnQuanApiService.getxingshiListBytravelname(travelname);
            List<HpDianZhaoDianPaiTypeNameInfo> levellist = shiGongAnQuanApiService.getlevelListBytravelname(travelname);
            resultJson.put("sizelist", sizelist);
            resultJson.put("heigthlevellist", heigthlevellist);
            resultJson.put("xingshilist", xingshilist);
            resultJson.put("levellist", levellist);
        }


        resultJson.put("listHpDianZhaoDianPaiInfo", listHpDianZhaoDianPaiInfo);

        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", resultJson);
        responseData(resultObj.toString(), resp);

    }


    /**
     * 根据店招店牌等级获取列表(A/B/C)
     */
    @RequestMapping(value = "/getAllHpDianZhaoDianPaiInfoByLevel")
    public void getAllHpDianZhaoDianPaiInfoByLevel(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getAllHpDianZhaoDianPaiInfoByLevel-----start-------");

        String str = getRequestBodyString(req);
        if (StringUtil.isEmpty(str)) {
            responseErrorData("json error", resp);
            return;
        }
        JSONObject jsonObject = JSONObject.parseObject(str);
        //施工工地ID
        String level = jsonObject.getString("level");


        List<HpDianZhaoDianPaiInfo> listHpDianZhaoDianPaiInfo = shiGongAnQuanApiService.llistHpDianZhaoDianPaiInfoLevel(level);
        for (HpDianZhaoDianPaiInfo ss : listHpDianZhaoDianPaiInfo) {
            double[] map = MapUtil.bd09towgs84(Double.parseDouble(ss.getBaiduLongitude()), Double.parseDouble(ss.getBaiduLatitude()));
            ss.setBaiduLongitude(map[0] + "");
            ss.setBaiduLatitude(map[1] + "");
        }

        resultJson.put("listHpDianZhaoDianPaiInfo", listHpDianZhaoDianPaiInfo);
        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", resultJson);
        responseData(resultObj.toString(), resp);

    }

    /**
     * 电招电牌图层详情
     */
    @RequestMapping(value = "/getHpDianZhaoDianPaiStreet")
    public void getHpDianZhaoDianPaiStreet(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getHpDianZhaoDianPaiStreet-----start-------");
        //半淞园街道
        Integer Bangsongcount = shiGongAnQuanApiService.getHpDianZhaoDianPaiStreetCount("半淞");
        //
        Integer Dapucount = shiGongAnQuanApiService.getHpDianZhaoDianPaiStreetCount("打浦");

        Integer Dongmencount = shiGongAnQuanApiService.getHpDianZhaoDianPaiStreetCount("东门");

        Integer huaihaicount = shiGongAnQuanApiService.getHpDianZhaoDianPaiStreetCount("淮海");

        Integer nandongcount = shiGongAnQuanApiService.getHpDianZhaoDianPaiStreetCount("南东");

        Integer ruijingcount = shiGongAnQuanApiService.getHpDianZhaoDianPaiStreetCount("瑞金");

        Integer waitangcount = shiGongAnQuanApiService.getHpDianZhaoDianPaiStreetCount("外滩");
        Integer wulicount = shiGongAnQuanApiService.getHpDianZhaoDianPaiStreetCount("五里");
        Integer ximengcount = shiGongAnQuanApiService.getHpDianZhaoDianPaiStreetCount("西门");
        Integer yuyuancount = shiGongAnQuanApiService.getHpDianZhaoDianPaiStreetCount("豫园");
        JSONObject fangtaifangxunjsonObject = new JSONObject();

        fangtaifangxunjsonObject.put("Bangsongcount", Bangsongcount);
        fangtaifangxunjsonObject.put("Dapucount", Dapucount);
        fangtaifangxunjsonObject.put("Dongmencount", Dongmencount);
        fangtaifangxunjsonObject.put("huaihaicount", huaihaicount);
        fangtaifangxunjsonObject.put("nandongcount", nandongcount);
        fangtaifangxunjsonObject.put("ruijingcount", ruijingcount);
        fangtaifangxunjsonObject.put("waitangcount", waitangcount);
        fangtaifangxunjsonObject.put("wulicount", wulicount);
        fangtaifangxunjsonObject.put("ximengcount", ximengcount);
        fangtaifangxunjsonObject.put("yuyuancount", yuyuancount);


        resultJson.put("streetjson", fangtaifangxunjsonObject);
        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", resultJson);
        responseData(resultObj.toString(), resp);

    }


    /**
     * 电招电牌列表
     */
    @RequestMapping(value = "/getAllHpDianZhaoDianPaiInfoByStreet")
    public void getAllHpDianZhaoDianPaiInfoByStreet(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getAllHpDianZhaoDianPaiInfoByStreet-----start-------");

        String str = getRequestBodyString(req);
        if (StringUtil.isEmpty(str)) {
            responseErrorData("json error", resp);
            return;
        }
        JSONObject jsonObject = JSONObject.parseObject(str);
        //施工工地ID
        String street = jsonObject.getString("street");
        List<HpDianZhaoDianPaiInfo> listHpDianZhaoDianPaiInfo = shiGongAnQuanApiService.llistHpDianZhaoDianPaiInfoStreet(street);
        listHpDianZhaoDianPaiInfo.forEach(item -> {
            item.setBaiduLatitude(item.getWgs84Latitude());
            item.setBaiduLongitude(item.getWgs84Longitude());
        });
        /*for (HpDianZhaoDianPaiInfo ss : listHpDianZhaoDianPaiInfo) {
            double[] map = MapUtil.bd09towgs84(Double.parseDouble(ss.getBaiduLongitude()), Double.parseDouble(ss.getBaiduLatitude()));
            ss.setBaiduLongitude(map[0] + "");
            ss.setBaiduLatitude(map[1] + "");
        }*/
        resultJson.put("listHpDianZhaoDianPaiInfo", listHpDianZhaoDianPaiInfo);
        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", resultJson);
        responseData(resultObj.toString(), resp);

    }


    /**
     * 电招电牌详情
     */
    @RequestMapping(value = "/getAllHpDianZhaoDianPaiInfo")
    public void getAllHpDianZhaoDianPaiInfo(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getAllHpDianZhaoDianPaiInfo-----start-------time：");

        List<HpDianZhaoDianPaiInfo> listHpDianZhaoDianPaiInfo = shiGongAnQuanApiService.llistHpDianZhaoDianPaiInfo();

        listHpDianZhaoDianPaiInfo.forEach(item -> {
            item.setBaiduLatitude(item.getWgs84Latitude());
            item.setBaiduLongitude(item.getWgs84Longitude());
        });

        resultJson.put("listHpDianZhaoDianPaiInfo", listHpDianZhaoDianPaiInfo);
        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", resultJson);
        responseData(resultObj.toString(), resp);

    }

    /**
     * 电招电牌详情
     */
    @RequestMapping(value = "/getAllHpDianZhaoDianPaiInfoTest")
    public void getAllHpDianZhaoDianPaiInfoTest(HttpServletRequest req, HttpServletResponse resp) throws Exception {

        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getAllHpDianZhaoDianPaiInfo-----start-------time：");

        List<HpDianZhaoDianPaiInfo> listHpDianZhaoDianPaiInfo = shiGongAnQuanApiService.llistHpDianZhaoDianPaiInfoTest();

        listHpDianZhaoDianPaiInfo.forEach(item -> {
            item.setBaiduLatitude(item.getWgs84Latitude());
            item.setBaiduLongitude(item.getWgs84Longitude());
            item.setWgs84Longitude(null);
            item.setWgs84Latitude(null);
        });

        resultJson.put("listHpDianZhaoDianPaiInfo", listHpDianZhaoDianPaiInfo);
        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", resultJson);
        responseData(resultObj.toString(), resp);

    }

    /**
     * 店招店牌撒点---新接口
     * street 为空查全部，否则查指定的 street
     */
    @RequestMapping(value = "listDianZhaoDianPai")
    public void listDianZhaoDianPai(@RequestBody DianZhaoDianPaiDto dianZhaoDianPaiDto,HttpServletResponse resp)throws Exception{
        List<HpDianZhaoDianPaiInfo> listHpDianZhaoDianPaiInfo = shiGongAnQuanApiService.listDianZhaoDianPai(dianZhaoDianPaiDto);
        listHpDianZhaoDianPaiInfo.forEach(item -> {
            item.setBla(item.getWgs84Latitude());
            item.setBlo(item.getWgs84Longitude());
            item.setWgs84Longitude(null);
            item.setWgs84Latitude(null);
        });
        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        resultJson.put("list", listHpDianZhaoDianPaiInfo);
        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", resultJson);
        responseData(resultObj.toString(), resp);
    }

    @RequestMapping(value = "getDianZhaoDianPai")
    public void getDianZhaoDianPaiInfo(@RequestBody DianZhaoDianPaiDto dianZhaoDianPaiDto, HttpServletResponse resp ) throws Exception{
        JSONObject resultObj = new JSONObject();
        if(dianZhaoDianPaiDto.getId() == null){
            resultObj.put("error_code", -1);
            resultObj.put("error_msg", "id不能为空");
            responseData(resultObj.toString(), resp);
            return;
        }
        HpDianZhaoDianPaiInfo hpDianZhaoDianPaiInfo= shiGongAnQuanApiService.getDianZhaoDianPai(dianZhaoDianPaiDto);
        JSONObject resultJson = new JSONObject();
        resultJson.put("DianZhaoDianPaiInfo", hpDianZhaoDianPaiInfo);
        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", resultJson);
        responseData(resultObj.toString(), resp);
    }


    /**
     * 电招电牌图层显示
     */
    @RequestMapping(value = "/getDianZaoDianPaiMap")
    public void getDianZaoDianPaiMap(HttpServletRequest req, HttpServletResponse resp) throws Exception {
        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getDianZaoDianPaiMap-----start-------");
        JSONObject ShiGongjsonObject = new JSONObject();
        //施工建筑
        Integer teamcount = shiGongAnQuanApiService.getDianZhaoDianpaiCount();
        ShiGongjsonObject.put("dianzhaodianpaicount", teamcount);
        resultJson.put("dianzhaodianpaicount", ShiGongjsonObject);
        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", resultJson);
        responseData(resultObj.toString(), resp);
    }


    /**
     * 图层数据
     */
    @RequestMapping(value = "/getShiGongMapEventItem")
    public void getShiGongMapEventItem(HttpServletRequest req, HttpServletResponse resp) throws Exception {
        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getShiGongMapEventItem-----start-------");
        JSONObject ShiGongjsonObject = new JSONObject();
        //施工建筑
        Integer teamcount = shiGongAnQuanApiService.listShiGongCountByStreet("老西门街道");
        ShiGongjsonObject.put("shigoungbuildingcount", 34);
        //玻璃幕墙
        Integer wallteamcount = shiGongAnQuanApiService.listShiGongWallByStreet();
        ShiGongjsonObject.put("buildingwallcount", wallteamcount);
        resultJson.put("ShiGongjsonObject", ShiGongjsonObject);
        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", resultJson);
        responseData(resultObj.toString(), resp);
    }


    /**
     * 施工安全-工地数据概览
     */
    @RequestMapping(value = "/getShiGongAnQuanAllData")
    public void getShiGongAnQuanAllData(HttpServletRequest req, HttpServletResponse resp) throws Exception {
        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        LogFactory.getLog(this.getClass()).info("------getShiGongAnQuanAllData-----start-------");
        //工地总数
        Integer buildingAllNum = shiGongAnQuanApiService.getBuildingAllNum();
        Integer buildingAllFocusNum = 0;
        Integer buildingAllVideosNum = 0;
        //工地所属街道
        List<SysBuildingStreetInfo> listSysBuildingStreetInfo = new ArrayList<SysBuildingStreetInfo>();
//        List<SysBuildingStreetInfo>  listSysBuildingStreetInfo=shiGongAnQuanApiService.getListSysBuildingStreetInfo();
        resultJson.put("buildingAllNum", buildingAllNum);
        resultJson.put("buildingAllFocusNum", buildingAllFocusNum);
        resultJson.put("buildingAllVideosNum", buildingAllVideosNum);
        resultJson.put("listSysBuildingStreetInfo", listSysBuildingStreetInfo);
        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", resultJson);
        responseData(resultObj.toString(), resp);
    }


    /**
     * 施工安全页面数据返回-工地数据列表(老西门街道)查询
     */
    @RequestMapping(value = "/getShiGongAnQuanBuildingListByKeyString")
    public void getShiGongAnQuanBuildingListByKeyString(HttpServletRequest req, HttpServletResponse resp) throws Exception {
        JSONObject resultObj = new JSONObject();

        String str = getRequestBodyString(req);
        if (StringUtil.isEmpty(str)) {
            responseErrorData("json error", resp);
            return;
        }
        JSONObject jsonObject = JSONObject.parseObject(str);
        //店名地址
        String keystring = jsonObject.getString("keystring");
        JSONObject resultJson = new JSONObject();
        JSONArray jsonArray = new JSONArray();
        LogFactory.getLog(this.getClass()).info("------getShiGongAnQuanBuildingListByKeyString-----start-------");
        List<SysBuildingInfoStreet> listSysBuildingInfo = shiGongAnQuanApiService.listSysBuildingInfoStreetByKeyString(keystring);
        if (listSysBuildingInfo != null && listSysBuildingInfo.size() > 0) {
            for (SysBuildingInfoStreet sysBuildingInfo : listSysBuildingInfo) {
                jsonObject = new JSONObject();
                double[] map = MapUtil.bd09towgs84(Double.parseDouble(sysBuildingInfo.getLng()), Double.parseDouble(sysBuildingInfo.getLat()));
                jsonObject.put("Longitude", map[0] + "");
                jsonObject.put("Latitude", map[1] + "");
                jsonObject.put("buildingId", sysBuildingInfo.getId());
                jsonObject.put("name", sysBuildingInfo.getName());
                jsonObject.put("address", sysBuildingInfo.getAddress());
                jsonObject.put("principal", sysBuildingInfo.getDepartment());
                jsonObject.put("connectmobile", sysBuildingInfo.getPhone());
                jsonObject.put("usepeople", sysBuildingInfo.getNumber());
                jsonArray.add(jsonObject);
            }
        }
        //resultJson.put("buildingAllNum", buildingAllNum);
        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", jsonArray);
        responseData(resultObj.toString(), resp);
    }

    /**
     * 施工安全页面数据返回-工地数据列表(老西门街道)
     */
    @RequestMapping(value = "/getShiGongAnQuanBuildingList")
    public void getShiGongAnQuanBuildingList(HttpServletRequest req, HttpServletResponse resp) throws Exception {
        JSONObject resultObj = new JSONObject();
        JSONObject resultJson = new JSONObject();
        JSONArray jsonArray = new JSONArray();
        JSONObject jsonObject = null;
        LogFactory.getLog(this.getClass()).info("------getShiGongAnQuanBuildingList-----start-------");
        //工地总数
        //Integer buildingAllNum=shiGongAnQuanApiService.getBuildingAllNum();
//        Integer buildingAllFocusNum=0;
//        Integer buildingAllVideosNum=0;
        //工地所属街道
//        List<SysBuildingInfo>  listSysBuildingInfo=shiGongAnQuanApiService.getShiGongAnQuanBuildingList();
        List<SysBuildingInfoStreet> listSysBuildingInfo = shiGongAnQuanApiService.listSysBuildingInfoStreet();
        if (listSysBuildingInfo != null && listSysBuildingInfo.size() > 0) {
            for (SysBuildingInfoStreet sysBuildingInfo : listSysBuildingInfo) {
                jsonObject = new JSONObject();
                double[] map = MapUtil.bd09towgs84(Double.parseDouble(sysBuildingInfo.getLng()), Double.parseDouble(sysBuildingInfo.getLat()));
                jsonObject.put("Longitude", map[0] + "");
                jsonObject.put("Latitude", map[1] + "");
                jsonObject.put("buildingId", sysBuildingInfo.getId());
                jsonObject.put("name", sysBuildingInfo.getName());
                jsonObject.put("address", sysBuildingInfo.getAddress());
                jsonObject.put("principal", sysBuildingInfo.getDepartment());
                jsonObject.put("connectmobile", sysBuildingInfo.getPhone());
                jsonObject.put("usepeople", sysBuildingInfo.getNumber());
                jsonArray.add(jsonObject);
            }
        }
        //resultJson.put("buildingAllNum", buildingAllNum);
        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", jsonArray);
        responseData(resultObj.toString(), resp);
    }


    /**
     * 施工安全页面数据返回-工地数据详情
     */
    @RequestMapping(value = "/getShiGongAnQuanBuildingInfo")
    public void getShiGongAnQuanBuildingInfo(HttpServletRequest req, HttpServletResponse resp) throws Exception {
        JSONObject resultObj = new JSONObject();

        String str = getRequestBodyString(req);
        if (StringUtil.isEmpty(str)) {
            responseErrorData("json error", resp);
            return;
        }
        JSONObject jsonObject = JSONObject.parseObject(str);
        //施工工地ID
        String buildingId = jsonObject.getString("buildingId");
        SysBuildingInfo sysBuildingInfo = shiGongAnQuanApiService.getSysBuildingInfoById(buildingId);
        resultObj.put("error_code", 0);
        resultObj.put("error_msg", "获取成功");
        resultObj.put("data", sysBuildingInfo);
        responseData(resultObj.toString(), resp);
    }

    /**
     * 从req中读取数据
     *
     * @param req
     * @return
     */
    private String getRequestBodyString(HttpServletRequest req) {
        StringBuilder builder = new StringBuilder();
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(req.getInputStream(), "utf-8"));
            String line;
            while ((line = br.readLine()) != null) {
                builder.append(line);
            }
        } catch (IOException e) {
            // e.printStackTrace();
            return null;
        }
        return builder.toString();
    }

    private void responseErrorData(String string, HttpServletResponse resp) throws Exception {
        // TODO Auto-generated method stub
        JSONObject resultObj = new JSONObject();
        resultObj.put("errorcode", 1);
        resultObj.put("message", string);
        responseData(resultObj.toString(), resp);
    }

    private void responseData(String string, HttpServletResponse resp) throws Exception {
        // TODO Auto-generated method stub
        responseDate("application/json;charset=UTF-8", string, resp);
    }

    private void responseDate(String contentType, String value, HttpServletResponse resp) throws Exception {
        resp.setContentType(contentType);
        resp.getWriter().write(value);
    }


    /**
     * 测试代码 批量更新
     */
   /* @RequestMapping(value = "/test")
    public void test(HttpServletRequest req, HttpServletResponse resp){
        //查询所有数据
        List<HpDianZhaoDianPaiInfo> hpDianZhaoDianPaiInfoList = shiGongAnQuanApiService.test();
        //坐标转换
        for (HpDianZhaoDianPaiInfo ss : hpDianZhaoDianPaiInfoList) {
            double[] map = MapUtil.bd09towgs84(Double.parseDouble(ss.getBaiduLongitude()), Double.parseDouble(ss.getBaiduLatitude()));
            ss.setBaiduLongitude(map[0] + "");
            ss.setBaiduLatitude(map[1] + "");
        }
        //批量更新
        System.out.println("hpDianZhaoDianPaiInfoList.size() = " + hpDianZhaoDianPaiInfoList.size());
        shiGongAnQuanApiService.branchUpdateTest(hpDianZhaoDianPaiInfoList);
    }*/

}
